﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>部门管理</title>
    <#include "../common/link.ftl">
    <script>
        $(function () {
            $("#editForm").bootstrapValidator({
                feedbackIcons: { //图标
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: { //配置要验证的字段
                    srcPassword: {
                        validators: { //验证的规则
                            notEmpty: { //不能为空
                                message: "原密码必填" //错误时的提示信息
                            },
                            remote: {
                                type: 'POST',
                                url: '/employee/updatePw.do',
                                data: function () {  //自定义提交参数，默认只会提交当前用户名input的参数
                                    return {
                                        id: $('[name="id"]').val(),
                                        srcPassword: $('[name="srcPassword"]').val()
                                    };
                                },
                                message: '密码不匹配',
                                delay: 1500
                            },
                        }
                    },
                    newPassword: {
                        validators: {
                            notEmpty: { //不能为空
                                message: "密码必填" //错误时的提示信息
                            },
                        }
                    },
                }
            }).on('success.form.bv', function () { //表单所有数据验证通过后执行里面的代码
                //提交异步表单
                $("#editForm").ajaxSubmit(function (data) {
                    if (data.success) {
                        $.messager.popup(data.msg + ',1秒后刷新');
                        setTimeout(function () {
                            location.href = '/employee/list.do';
                        }, 2000)
                    } else {
                        $.messager.alert('温馨提示', data.msg)
                    }
                })
            });

        })
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../common/navbar.ftl">
    <!--菜单回显-->
    <#--    <c:set var="currentMenu" value="department"/>-->
    <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>修改密码</h1>
        </section>
        <section class="content">
            <div class="box">
                <form class="form-horizontal" action="/employee/updatePassword.do" method="post" id="editForm">
                    <input type="hidden" value="${id!}" name="id">
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="name" class="col-sm-1 control-label">原密码：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" id="srcPassword" name="srcPassword"
                                   placeholder="请输入原密码">
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sn" class="col-sm-1 control-label">新密码：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" id="newPassword" name="newPassword"
                                   placeholder="请输入新密码">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-1 col-sm-6">
                            <button id="submitBtn" type="submit" class="btn btn-primary">确认修改</button>
                        </div>
                    </div>

                </form>

            </div>

        </section>
    </div>
    <#include "../common/footer.ftl">
</div>
</body>
</html>
